{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# C++的标识符"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. 标识符"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "① 标识符就是 C++ 给变量、常量的命名。\n",
    "\n",
    "② 标识符有一套自己的命名规则：\n",
    "\n",
    "1. 标识符不能使关键字。\n",
    "2. 标识符只能由字母、数字、下划线组成。\n",
    "3. 第一个字符必须为字母或下划线。\n",
    "4. 标识符中字母区分大小写。\n",
    "\n",
    "③ 建议：给标识符命名时，争取做到见名知意，方便自己和他人的阅读。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#include <iostream>\n",
    "using namespace std;\n",
    "\n",
    "int main()\n",
    "{\n",
    "    //1、标识符不可以是关键字\n",
    "    //int int = 10;  //报错\n",
    "    \n",
    "    //2、标识符由字母、数字、下划线构成\n",
    "    int abc       =   10;\n",
    "    int _abc      =   20;\n",
    "    int _123abc   =   40;\n",
    "    \n",
    "    //3、标识符第一个字符只能是字母或下划线\n",
    "    //int 123abc = 50; //报错\n",
    "\n",
    "    //4、标识符区分大小写\n",
    "    int aaa = 100;\n",
    "    //cout << AAA << endl; //报错，AAA和aaa不是同一个名称\n",
    "\n",
    "    //建议：给变量起名的时候，最好能够做到见名知意\n",
    "    int num1 = 10;\n",
    "    int num2 = 20;\n",
    "    int sum = num1 + num2; //建议用num1、num2、sum表示加法，而不是用a、b、c来表示\n",
    "    cout << sum << endl;\n",
    "\n",
    "    system(\"pause\");\n",
    "\n",
    "    return 0;\n",
    "\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "运行结果：  \n",
    " - 30\n",
    " - 请按任意键继续. . ."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.6.3",
   "language": "python",
   "name": "python3.6.3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
